import {detail} from '../../utils/interface'
Page({
  data: {
    show: false,
    detailObj:{},
  },
  onLoad(e){
    let {id} = e
    this.getDetail(id)
  },
  async getDetail(i){
    let {data:res} = await detail({id:i})
    // console.log(res);
    this.setData({
      detailObj:res.data
    })
  },
  handleBack() {
    wx.navigateBack()
  },
  //显示弹出层
  showPop() {
    this.setData({
      show: true,
    });
  },
  //关闭弹出层
  onClose() {
    this.setData({
      show: false,
    });
  },
  // 点击添加购物车后关闭模态框
  cartAdd(e){
    this.setData({
      show:e.detail
    })
  },
  // 点击购物车跳转
  goCart(){
    wx.switchTab({
      url: '/pages/cart/cart',
    })
  },
  // 大图展示
  proviewImg(e){
    let {imgUrl} = e.currentTarget.dataset
    let arr = this.data.detailObj.pics.map(item =>{
      return item.pic
    })
    wx.previewImage({
      urls:arr,
      current:imgUrl,
      showmenu:true
    })
  }
});
